<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <%layout("/WEB-INF/view/common/inc/admin_head.html",{title:'登录',
    styles:'bootstrap,font-awesome,animate,style,login,outdatedbrowser'}){}%>
</head>
<body>
<div class="text-center" >
    <!--<img src="${ctxPath}/assets/img/title.jpg">-->
    <h1>BOSS内部系统开发框架v1.0.0</h1>
</div>

<div class="row fupin-login-panel">

    <div class="signinpanel">
        <div class="row">
            <div class="col-sm-12">
                <form id="login-form">
                    <h3 class="no-margins">登录</h3>
                    <h4 id="error-tip"></h4>
                    <input type="text" name="ac" class="form-control uname" placeholder="用户名"/>
                    <input type="password" name="pwd" class="form-control pword m-b" placeholder="密码"/>
                    <button type="button" class="login-btn btn btn-primary btn-block" style="width: 70px;">登录</button>
                </form>
            </div>
        </div>

    </div>
</div>


<div id="outdated"></div>
<%layout("/WEB-INF/view/common/inc/admin_js.html",{modules:'jquery-1.11,bootstrap,layer,outdatedbrowser'}){}%>
</body>
<script>
    var back_url = '${backUrl!""}';
    $(function () {
        $('.login-btn').on('click', function () {
            doLogin();
        });

        $(document).keyup(function (e) {
            var curKey = e.which;
            if(curKey==13 && $("input[name='ac']").val() != '' && $("input[name='pwd']").val() != '' ){
                doLogin();
            }
        });

        //用户登录
        function doLogin() {
            layer.load();
            $('#error-tip').html('<span class="label label-info">登录中...</span>');
            $.post('${ctxPath}/admin/login.do', $('#login-form').serialize(), function (data) {
                if (data.ok) {
                    $('#error-tip').html('<span class="label label-success">' + data.msg + '</span>');
                    if (back_url == '${ctxPath}/' || back_url == '') {
                        location.href = "${ctxPath}/admin/index.do";
                    } else {
                        location.href = back_url;
                    }
                } else {
                    $('#error-tip').html('<span class="label label-warning">' + data.msg + '</span>');
                }
            }, 'json');
            layer.closeAll('loading');
        }

        outdatedBrowser({
            bgColor: '#f25648',
            color: '#ffffff',
            lowerThan: 'transform',
            languagePath: '${ctxPath}/assets/js/plugins/outdatedbrowser/lang/zh-cn.html'
        })

    });
</script>
</html>
